package com.zyh.demo.homework.test1;

import com.zyh.demo.homework.test1.domain.Student;

import java.lang.reflect.Method;
import java.util.Scanner;

/**
 * @Author zyh
 * @Date 2024/8/14 19:07
 * @Description
 */

public class TestStudent {
    public static void main(String[] args){
        try {
            Scanner input=new Scanner(System.in);
            System.out.println("请输入学生的信息（格式：姓名：年龄：成绩，使用:分隔）");
            String studentInfo = input.next();
            String[] split = studentInfo.split(":");
            Class c = Class.forName("com.zyh.demo.homework.test1.domain.Student");
            Student student = (Student) c.getDeclaredConstructor(String.class, int.class, float.class).newInstance(split[0],Integer.parseInt(split[1]),Float.parseFloat(split[2]));
            Method toString = c.getDeclaredMethod("toString");
            System.out.println(toString.invoke(student));
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
